using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using NTTHAO.Common.BL;

public partial class admin_webparts_URLSecurity_URLSecurityList : System.Web.UI.UserControl
{
    public DataTable _URLList = null;
    public DataTable _UserList = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        NTTHAO.Common.BL.AdminUser loggedUser;
        try
        {
            loggedUser = new NTTHAO.Common.BL.AdminUser(Context.User.Identity.Name);
            if (loggedUser.ID < 1)
            {
                throw new Exception();
            }
        }
        catch (Exception)
        {
            System.Web.Security.FormsAuthentication.SignOut();
            System.Web.Security.FormsAuthentication.RedirectToLoginPage();
            return;
        }

        NTTHAO.Common.BL.URLMap urlMap = new NTTHAO.Common.BL.URLMap();
        try
        {
            DataSet ds = null;
            if (loggedUser.UserName.Trim().Equals("admin", StringComparison.OrdinalIgnoreCase))
            {
                ds = urlMap.GetAll();
            }
            else
            {
                ds = urlMap.GetAllEditableUrl();
            }

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                _URLList = ds.Tables[0];
            }
        }
        catch (Exception)
        { }

        try
        {
            DataSet ds = loggedUser.GetAllByID(loggedUser.ID);
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                _UserList = ds.Tables[0];
            }
        }
        catch (Exception)
        { }
    }
}
